package com.community.process._1010.controller;


import com.community.process._1010.common.api.CommonResult;
import com.community.process._1010.dao.view.ProcessFoodItemView;
import com.community.process._1010.dao.vo.ProcessFoodItemIngredientsVo;
import com.community.process._1010.dao.vo.ProcessFoodItemVo;
import com.community.process._1010.domains.ProcessFoodItemDTO;
import com.community.process._1010.service.ProcessFoodItemService;
import com.oneadds.lowcode.dto.PageListData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 到餐加工成品菜 前端控制器
 *
 * @author Zbs
 * @since 2024-09-05
 */
@RestController
@Tag(name = "到餐加工成品菜")
@RequestMapping("/process/food/item")
@RequiredArgsConstructor
public class ProcessFoodItemController {
    
    private final ProcessFoodItemService processFoodItemService;

    @PostMapping("/addProcessFoodItem")
    @Operation(summary = "添加菜品")
    public CommonResult<String> addProcessFoodItem(@RequestBody @Valid ProcessFoodItemDTO.FoodItemAdd dto) {
        this.processFoodItemService.addProcessFoodItem(dto);
        return CommonResult.success("");
    }

    @PostMapping("/updateProcessFoodItem")
    @Operation(summary = "更新菜品")
    public CommonResult<String> updateProcessFoodItem(@RequestBody @Valid ProcessFoodItemDTO.FoodItemUpdate dto) {
        this.processFoodItemService.updateProcessFoodItem(dto);
        return CommonResult.success("");
    }

    @PostMapping("/deleteProcessFoodItem")
    @Operation(summary = "删除菜品")
    public CommonResult<String> deleteProcessFoodItem(@RequestBody @Valid ProcessFoodItemDTO.FoodItemDelete dto) {
        this.processFoodItemService.deleteProcessFoodItem(dto);
        return CommonResult.success("");
    }

    @PostMapping("/getProcessFoodItemVoPageList")
    @Operation(summary = "成品菜列表")
    public CommonResult<PageListData<ProcessFoodItemVo>> getProcessFoodItemVoPageList(@RequestBody @Valid ProcessFoodItemDTO.FoodItemPageSearch dto) {
        PageListData<ProcessFoodItemVo> view = this.processFoodItemService.getProcessFoodItemVoPageList(dto);
        return CommonResult.success(view);
    }

    @PostMapping("/getProcessFoodItemView/{id}")
    @Operation(summary = "成品菜详情")
    public CommonResult<ProcessFoodItemView> getProcessFoodItemView(@PathVariable Long id) {
        ProcessFoodItemView view = this.processFoodItemService.getProcessFoodItemView(id);
        return CommonResult.success(view);
    }
}

